import {createNav} from "plain-micro-application";
import {computed, reactive} from "plain-design-composition";
import {$$notice} from 'plain-design'
import {loadVue3Dependency} from "@/micro/app/vue3/loadVue3Dependency";
import {MicroLibService} from "@/micro/utils/MicroLibService";

export const nav = createNav({
    MicroLib: MicroLibService,
    /*在nav中有时候需要在页面上显示错误信息，因为plain-micro-application没有用到组件库，并且为了风格统一，由开发者自定义显示错误信息的方式*/
    showError: msg => {
        /*一开始的时候，可能应用没有挂载完毕，这里延迟一会*/
        setTimeout(() => $$notice.error(msg), 100)
    },

    /*plain-micro-application需要用到几个响应式api*/
    reactive: reactive as any, computed,
    beforeLoadMicroApplication: async app => {
        /*加载子应用依赖*/
        switch (app.config.type) {
            case "Vue3":
                await loadVue3Dependency()
                break
            case "Vue2":
                // await loadVue2Dependency()
                break
            case "React":
                // await loadReactDependency()
                break
        }
    }
})
